package com.timesheet.server.dao;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import org.hibernate.Criteria;
import org.hibernate.SQLQuery;
import org.hibernate.Session;

import com.timesheet.server.core.util.HibernateUtil;

public class Test {
	public List getAllEffortsInBetweenDates(Date fromDate, Date toDate) {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy",
				Locale.ENGLISH);
	//	Date date = simpleDateFormat.parse(date);

		HibernateUtil hibenateUtil = new HibernateUtil();
		Session session = hibenateUtil.getSession();

		String sql = "SELECT * FROM EFFORTTRACKER";
		SQLQuery query = session.createSQLQuery(sql);
		query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
		query.setParameter("from", fromDate);
		query.setParameter("to", toDate);
		List results = query.list();
		System.out.println(results);
		return query.list();

	}

	public static void main(String[] args) {
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy",
				Locale.ENGLISH);
	//	Date date = simpleDateFormat.parse(date);
		Test test = new Test();
		//test.getAllEffortsInBetweenDates();

	}
}
